<?php
class M_admin extends CI_Model
{
    public $data;
    
	public function __construct()
	{
		parent::__construct();
		// Your own constructor code
	}
 
    public function get_insert()
    {     
        
        $data = array(
            'fullname'   =>$this->input->post('username'),
            'user'    =>$this->input->post('user'),
            'password'   =>sha1($this->input->post('password')),
            'state'   =>$this->input->post('state')
            ); 
             $result = $this->db->insert('login', $data);
            return $result;
            $result->free_result();;
    }
        
    public function get_select()
    {     
        $this->db->select('*');
        $this->db->from('login');
        $result = $this->db->get();
        return $result;
        $result->free_result();
    }
    
    function get_delete($id) 
    {
        if(!empty($id)){
            $this->db->where('id_user', $id);
            $result = $this->db->delete('login');
            if($result){
                return true;
            }else{
                return false;
            }
        }
        return false;
    }
    public function get_update($id)
    {
        $data = array(
            'fullname'   =>$this->input->post('username'),
            'user'    =>$this->input->post('user'),
            'password'   =>sha1($this->input->post('password')),
            'state'   =>$this->input->post('state')
            ); 
        $this->db->where('id_user', $id);
        $this->db->update('login', $data);  
        return $result;
        $result->free_result();; 
    }
   
}